<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>cscms产品 - Powered by cscms</title>
<link rel="stylesheet" href="<?=install_path?>packs/install/images/css.css" />
<script type="text/javascript" src="<?=install_path?>packs/js/jquery.min.js"></script>
</head>
<body>
	<div class="wrap">
		<div class="header">
			<h1 class="logo">logo</h1>
					<div class="icon_install">安装向导</div>
					<div class="version">v4</div>
		</div><div class="section">
	<div class="step">
		<ul>
			<li class="on"><em>1</em>检测环境</li>
			<li class="current"><em>2</em>创建数据</li>
			<li><em>3</em>完成安装</li>
		</ul>
	</div>
	<form id="J_install_form" action="<?=install_url?>save3" method="post">
	<div class="server">
		<table width="100%">
			<tr>
				<td class="td1" width="100">数据库信息</td>
				<td class="td1" width="200">&nbsp;</td>
				<td class="td1">&nbsp;</td>
			</tr>
			<tr>
				<td class="tar">数据库类型：</td>
				<td>
                      <select class="select1" id="dbdriver" name="dbdriver">
                           <option value="mysql">Mysql</option>
                           <option value="mysqli"<?php if(function_exists("mysqli_connect")) echo ' selected';?>>Mysqli</option>
                           <option value="pdo">Pdo</option>
                           <option value="mssql">Mssql</option>
                      </select>
                </td>
				<td><div id="J_dbdriver"><span class="gray">一般为Mysql，PHP5.6以上请选择Mysqli</span></div></td>
			</tr>
			<tr>
				<td class="tar">数据库服务器：</td>
				<td><input type="text" name="dbhost" id="dbhost" value="127.0.0.1" class="input"></td>
				<td><div id="J_dbhost"><span class="gray">数据库服务器地址，一般为127.0.0.1</span></div></td>
			</tr>
			<tr>
				<td class="tar">数据库用户名：</td>
				<td><input type="text" name="dbuser" id="dbuser" value="root" class="input"></td>
				<td><div id="J_dbuser"><span class="gray">数据库用户名</span></div></td>
			</tr>
			<tr>
				<td class="tar">数据库密码：</td>
				<td><input type="text" name="dbpwd" id="dbpwd" value="" class="input" autoComplete="off"></td>
				<td><div id="J_dbpwd"><span class="gray">数据库密码</span></div></td>
			</tr>
			<tr>
				<td class="tar">数据库名：</td>
				<td><input type="text" name="dbname" id="dbname" value="cscms" class="input"></td>
				<td><div id="J_dbname"><span class="gray">数据库名称</span></div></td>
			</tr>
			<tr>
				<td class="tar">数据库表前缀：</td>
				<td><input type="text" name="dbprefix" id="dbprefix" value="v41_" class="input"></td>
				<td><div id="J_dbprefix"><span class="gray">建议使用默认，同一数据库安装多个cscms时需修改</span></div></td>
			</tr>
		</table>
		<div id="J_response_tips" style="display:none;"><div class="loading"><span>请稍后...</span></div></div>
	</div>
	<div class="bottom tac">
		<a href="<?=install_url?>save1" class="btn">上一步</a><button onClick="checkdb();return false;" type="botton" class="btn btn_submit J_install_btn">创建数据</button>
	</div>
</form>
</section>
	</div>

	<div class="footer">
		&copy; 2008-2014 <a href="http://www.chshcms.com" target="_blank">chshcms.com</a>（桂林崇胜网络科技有限公司旗下品牌）
	</div>
<script language="JavaScript">
<!--
var errmsg = new Array();
errmsg[0] = '您已经安装过Cscms，系统会自动删除老数据！是否继续？';
errmsg[2] = '无法连接数据库服务器，请检查配置！';
errmsg[3] = '成功连接数据库，但是指定的数据库不存在并且无法自动创建，请先通过其他方式建立数据库！';
errmsg[5] = './cscms/lib/Cs_DB.php文件没有修改权限，请先增加权限！';

function checkdb() {
    $('#J_response_tips').html('<div class="loading"><span>请稍后...</span></div>');
    $('#J_response_tips').show();
    var url='<?=install_url?>dbtest?dbdriver='+encodeURIComponent($('#dbdriver').val())+'&dbhost='+encodeURIComponent($('#dbhost').val())+'&dbuser='+encodeURIComponent($('#dbuser').val())+'&dbpwd='+encodeURIComponent($('#dbpwd').val())+'&dbname='+encodeURIComponent($('#dbname').val())+'&dbprefix='+encodeURIComponent($('#dbprefix').val())+'&sid='+Math.random()*5;
    $.get(url, function(data){
		if(data > 1) {
			alert(errmsg[data]);
			$('#J_response_tips').hide();
			return false;
		}
		else if(data == 0 || (data == 1 && confirm(errmsg[0]))) {
			$('#J_install_form').submit();
		}
		$('#J_response_tips').hide();
    });
}
//-->
</script>
</body>
</html>